//
//  CoreData.h
//  MoneyIndividual
//
//  Created by Le Anh Tai on 1/6/14.
//  Copyright (c) 2014 Le Anh Tai. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface CoreData : NSObject

@property (nonatomic, strong) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, strong) NSManagedObjectModel *managedObjectModel;
@property (nonatomic, strong) NSPersistentStoreCoordinator *persistentStoreCoordinator;
@property (nonatomic, strong) NSArray *accounts;

+ (CoreData *)shared;

- (void)saveContext;

- (void)importData:(NSString *)fileName;

- (NSManagedObject *)newEntity:(NSString *)entityName;
- (NSArray *)fetchEntity:(NSString *)entityName;
- (NSArray*)fetchEntity:(NSString*)entityName withCondition:(NSString*)condition sortAttribute:(NSString*)attribute isAscending:(BOOL)isAscending;
- (BOOL)deleteObject:(NSManagedObject *)object;

- (NSManagedObject*)getAccountByType:(TransactionType)type;

@end
